package br.com.fsa.aplication.Database;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import br.com.fsa.aplication.Exception.ConectionException;
import br.com.fsa.aplication.Model.bean.Logistica;
import br.com.fsa.aplication.Util.HibernateUtil;
import br.com.fsa.aplication.Util.Util;

public class LogisticaDAO extends DaoGenericoImpl<Logistica> {

	public Logistica findLogisticaByCodigo(long id) throws ConectionException
	{
	
		try
		{
			Session mySessao = HibernateUtil.getSession().openSession();
			return (Logistica) mySessao.createCriteria(Logistica.class)
					.add(Restrictions.eq("codLog", id)).uniqueResult();
		}
		catch (HibernateException e)
		{
			Util.gravaLog(e.getMessage());
			throw new ConectionException(e.getMessage());

		}
	}
	
}
